#include <iostream>

using namespace std;
const int N=1e3+10;
int a[N];
int f[N],len;
int main()
{
	int n;
	cin>>n;
	
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	f[1]=a[1];
	len=1;
	for(int i=2;i<=n;i++)
	{
		
		if(a[i]>f[len])
		{
			f[++len]=a[i];
		}
		else{
			int left=1,right=len;
			while(left<right)
			{
				int mid=left+(right-left)/2;
				if(a[i]>f[mid])
				{
					left=mid+1;
				}
				else{
					right=mid;
				}
			}	
			f[right]=a[i];	
		}
	}
	
	cout<<len<<endl;
	return 0;
}
